import java.util.Arrays;

public class test {
    public static void main(String[] args) {


       /* for (int i = 0; i < arr1.length ; i++) {
            System.out.print(arr1[i]);
        }
        System.out.println();
        for (int x:arr1) {
            System.out.print(x);

        }
        System.out.println();
        arr1 = fun1();
        for (int i = 0; i < arr1.length ; i++) {
            System.out.print(arr1[i]);
        }
        arr1 = null;
        arr1[1] = 0;


    }
    public static int [] fun1() {
        int[]arr = {1,3,4,5,6};
        return arr;

    }*/

//        int[] arr1 = new int[]{1,2,3,4,5};
//        int [] newArr = arr1;
//        //arr1 和newArr 应用同一个对象 改变newArr 或arr1其中一个数组的值应该另一个也会遍
//        System.out.println("(arr1和newArr引用同一个对像) 测试:");
//        arr1[2] = 0;
//        newArr [4] = 0;
//        System.out.print(Arrays.toString(arr1));
//        System.out.println();
//        System.out.print(Arrays.toString(arr1));
//        //Arrays.copyOf()创建新数组对象
//        newArr = Arrays.copyOfRange(arr1,0,3);
//        System.out.println();
//        System.out.println("（拷贝后）测试");
//        //  arr1[0] = 0;
//        newArr [0] = 4444;
//        System.out.print(Arrays.toString(arr1));
//        System.out.println();
//        System.out.print(Arrays.toString(newArr));

            int[] arr = {1,2,3,4,5,6};
            System.out.println(avg(arr));


    }
    public static double avg(int[] arr) {
        int sum = 0;
        for (int x : arr) {
            sum += x;
        }
        return (double) sum / arr.length;

    }
}
